﻿
#include "EGraphics.h"
#include "EWindow.h"
#include "EMeshUtil.h"
#include "EUtil.h"
#include "EGame.h"
#include "../res/resource.h"

using namespace Base3D;
/*
 * import core
 * import engine
 * new SceneManager
 * render
 * gl
 * show a bmp
 *
 */
class Game:public EGame{

};

/**
 * redesign:
 *  WndProc:
 *      inputListener
 * EGame:
 *  keyPress
 * Game::Update
 *
 */
int WINAPI WinMain(
				   HINSTANCE hInstance,      // handle to current instance
				   HINSTANCE hPrevInstance,  // handle to previous instance
				   LPSTR lpCmdLine,          // command line
				   int nCmdShow              // show state
				   )
{	
	InitLog("Base3D.Log");
    //static
	Log("Init Graphics...");
	EGraphics::initGraphics(hInstance);
	Log("Graphics Load Succeed!");

	//
	EGameWindow::GWindow = new EGameWindow("Base3D [3DTankWar]", hInstance);
	EGameWindow::GWindow->showWindow(true);

	// 设置游戏的小图标
	HWND hwnd = EGameWindow::GWindow->getHWnd();
	//
	//LONG iconID = (LONG)LoadIcon(::GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_ICON_TANKWAR));
	//::SetClassLong(hwnd, GCL_HICON, iconID);

    //
	auto *game = new EGame;
	//onPaint
	EGameWindow::GWindow->setCanvasListener(game);
	//onKeyDown
	EGameWindow::GWindow->addInputListener(game);
	//
	EGameWindow::GWindow->startLoop();

	Log("Shutdown Graphics...");
	EGraphics::shutdownGraphics();

	CloseLog();

	return 0;
}